package com.naiterui.ehp.bs.esign.repository.mysql;

import java.util.Date;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bs.esign.entity.mysql.EsignNoSecret;

/**
 * 免密签署记录
 *
 * @author yangfuya
 * @version 1.0
 * @date 2021/4/28 19:33
 **/
public interface IEsignNoSecretRepository extends BaseJpaRepository<EsignNoSecret, Long> {

    /**
     * 获取免签签署记录
     * 
     * @param signUserId
     * @param signUserType
     * @param status
     * @return
     */
    EsignNoSecret findFirstBySignUserIdAndSignUserTypeAndStatusOrderByCreatedAtDesc(Long signUserId,
        Integer signUserType, Integer status);

    /**
     * 修改免密签署记录
     */
    @Modifying
    @Query(value = "update esign_no_secret set sign_url = ?1, status = ?2, sign_time = ?3 where id = ?4",
        nativeQuery = true)
    void updateSignUrlStatusSignTime(String signUrl, Integer status, Date signTime, Long id);
}
